﻿<Window
    x:Class="ColorWheel.Win.GradientColor.Demo.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:MSThemes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
    xmlns:core="clr-namespace:ColorWheel.Core;assembly=ColorWheel.Core"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    Title="Color Gradient Demo"
    Height="733"
    Width="794"
    Background="LightGray"
    Loaded="Window_Loaded"
    TextOptions.TextRenderingMode="ClearType"
    TextOptions.TextHintingMode="Animated"
    FontFamily="Segoe UI"
    FontSize="12"
    xmlns:my="clr-namespace:ColorWheel.Controls;assembly=ColorWheel.Controls">

    <Window.Resources>

        <core:ColorManager
            x:Key="ColorManager" />

        <Style
            x:Key="ButtonFocusVisual">

            <Setter
                Property="Control.Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Rectangle
                            Margin="2"
                            SnapsToDevicePixels="true"
                            Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
                            StrokeThickness="1"
                            StrokeDashArray="1 2" />
                    </ControlTemplate>
                </Setter.Value>
            </Setter>

        </Style>

        <Style
            x:Key="CustomButtonStyle"
            TargetType="{x:Type Button}">

            <Setter
                Property="FocusVisualStyle"
                Value="{StaticResource ButtonFocusVisual}" />

            <Setter
                Property="Background"
                Value="{Binding Source={StaticResource ButtonBackgroundBrush}, Path=Brush,  Mode=OneWay}" />

            <Setter
                Property="BorderBrush"
                Value="{Binding Source={StaticResource ButtonNormalBorder}, Path=Brush,  Mode=OneWay}" />

            <Setter
                Property="BorderThickness"
                Value="1" />

            <Setter
                Property="Foreground"
                Value="{Binding Source={StaticResource ButtonForeground}, Path=Brush,  Mode=OneWay}" />

            <Setter
                Property="HorizontalContentAlignment"
                Value="Center" />

            <Setter
                Property="VerticalContentAlignment"
                Value="Center" />

            <Setter
                Property="Padding"
                Value="1" />

            <Setter
                Property="Template">

                <Setter.Value>
                    <ControlTemplate
                        TargetType="{x:Type Button}">

                        <Grid>
                            <Border
                                BorderThickness="{TemplateBinding BorderThickness}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                CornerRadius="2"
                                Background="{TemplateBinding Background}"
                                SnapsToDevicePixels="true">
                            </Border>
                            
                            <ContentPresenter
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                Margin="{TemplateBinding Padding}"
                                RecognizesAccessKey="True"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                            
                        </Grid>

                        <ControlTemplate.Triggers>
                            <Trigger
                                Property="IsMouseOver"
                                Value="true">

                                <Setter
                                    Property="Background"
                                    Value="{Binding Source={StaticResource ButtonMouseOverBackground}, Path=Brush,  Mode=OneWay}" />

                            </Trigger>

                            <Trigger
                                Property="IsPressed"
                                Value="True">

                                <Setter
                                    Property="Background"
                                    Value="{Binding Source={StaticResource ButtonBackgroundIsPressed}, Path=Brush,  Mode=OneWay}" />

                            </Trigger>

                            <Trigger
                                Property="ToggleButton.IsChecked"
                                Value="true">
                            </Trigger>

                            <Trigger
                                Property="IsEnabled"
                                Value="false">

                                <Setter
                                    Property="Foreground"
                                    Value="{Binding Source={StaticResource ButtonDisabledForeground}, Path=Brush,  Mode=OneWay}" />

                            </Trigger>

                            <Trigger
                                Property="IsEnabled"
                                Value="false">

                                <Setter
                                    Property="Foreground"
                                    Value="{Binding Source={StaticResource ButtonDisabledForeground}, Path=Brush,  Mode=OneWay}" />

                            </Trigger>

                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style
            TargetType="{x:Type ListBox}">
            <Setter
                Property="Background"
                Value="{Binding Source={StaticResource ControlBackground}, Path=Brush,  Mode=OneWay}" />
            <Setter
                Property="BorderBrush"
                Value="{Binding Source={StaticResource ControlBorder}, Path=Brush,  Mode=OneWay}" />

            <Setter
                Property="BorderThickness"
                Value="1" />

            <Setter
                Property="Foreground"
                Value="{Binding Source={StaticResource ControlForeground}, Path=Brush,  Mode=OneWay}" />

            <Setter
                Property="ScrollViewer.HorizontalScrollBarVisibility"
                Value="Auto" />

            <Setter
                Property="ScrollViewer.VerticalScrollBarVisibility"
                Value="Auto" />

            <Setter
                Property="ScrollViewer.CanContentScroll"
                Value="true" />

            <Setter
                Property="ScrollViewer.PanningMode"
                Value="Both" />

            <Setter
                Property="Stylus.IsFlicksEnabled"
                Value="False" />

            <Setter
                Property="VerticalContentAlignment"
                Value="Center" />

            <Setter
                Property="Template">
                <Setter.Value>
                    <ControlTemplate
                        TargetType="{x:Type ListBox}">
                        <Border
                            x:Name="Bd"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Background="{TemplateBinding Background}"
                            Padding="1"
                            SnapsToDevicePixels="true">

                            <ScrollViewer
                                Focusable="false"
                                Padding="{TemplateBinding Padding}">
                                <ItemsPresenter
                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                            </ScrollViewer>

                        </Border>
                        <ControlTemplate.Triggers>

                            <Trigger
                                Property="IsGrouping"
                                Value="true">
                                <Setter
                                    Property="ScrollViewer.CanContentScroll"
                                    Value="false" />

                            </Trigger>

                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style
            TargetType="{x:Type ListBoxItem}">
            <Setter
                Property="Background"
                Value="Transparent" />

            <Setter
                Property="Foreground"
                Value="{Binding Source={StaticResource ControlHighlightForeground}, Path=Brush, Mode=OneWay}" />

            <Setter
                Property="HorizontalContentAlignment"
                Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />

            <Setter
                Property="VerticalContentAlignment"
                Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />

            <Setter
                Property="Padding"
                Value="2,2,2,2" />

            <Setter
                Property="Template">
                <Setter.Value>
                    <ControlTemplate
                        TargetType="{x:Type ListBoxItem}">

                        <Border
                            x:Name="Bd"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Background="{TemplateBinding Background}"
                            Padding="{TemplateBinding Padding}"
                            SnapsToDevicePixels="true">

                            <ContentPresenter
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                VerticalAlignment="Center" />

                        </Border>

                        <ControlTemplate.Triggers>
                            <Trigger
                                Property="IsSelected"
                                Value="true">

                                <Setter
                                    Property="Background"
                                    TargetName="Bd"
                                    Value="{Binding Source={StaticResource ControlHighlight}, Path=Global[ControlHighlight-3d-Light], Mode=OneWay}" />

                                <Setter
                                    Property="Foreground"
                                    Value="{Binding Source={StaticResource ControlHighlightForeground}, Path=Brush, Mode=OneWay}" />

                            </Trigger>

                            <MultiTrigger>

                                <MultiTrigger.Conditions>
                                    <Condition
                                        Property="IsSelected"
                                        Value="true" />

                                    <Condition
                                        Property="Selector.IsSelectionActive"
                                        Value="false" />

                                </MultiTrigger.Conditions>

                                <Setter
                                    Property="Background"
                                    TargetName="Bd"
                                    Value="{Binding Source={StaticResource ControlHighlight}, Path=Global[ControlHighlight-3d-Dark], Mode=OneWay}" />

                                <Setter
                                    Property="Foreground"
                                    Value="{Binding Source={StaticResource ControlHighlight}, Path=Brush, Mode=OneWay}" />

                            </MultiTrigger>

                            <Trigger
                                Property="IsEnabled"
                                Value="false">

                                <Setter
                                    Property="Foreground"
                                    Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />

                            </Trigger>

                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    </Window.Resources>

    <Grid
        VerticalAlignment="Stretch"
        HorizontalAlignment="Stretch"
        Background="{Binding Source={StaticResource DarkLinenTile}, Path=Brush, Mode=OneWay}">
        
        <Button
            Content="Button Text"
            HorizontalAlignment="Left"
            Margin="12,12,0,0"
            VerticalAlignment="Top"
            Width="243"
            Height="40"
            FontFamily="Tahoma"
            FontSize="16"
            Style="{DynamicResource CustomButtonStyle}" />

        <my:ColorWheelControl
            Palette="{Binding Palette, Mode=OneWay}"
            HorizontalAlignment="Left"
            Margin="261,12,0,0"
            Name="colorWheelControl1"
            VerticalAlignment="Top"
            Height="493"
            Width="503"
            PaintMethod="InverseLuminance" />

        <my:BrightnessSaturationControl
            Palette="{Binding Palette, Mode=OneWay}"
            HorizontalAlignment="Left"
            Foreground="Black"
            Height="179"
            Width="503"
            Margin="261,511,0,0"
            Name="brightnessSaturationControl1"
            VerticalAlignment="Top" />

        <ListBox
            Height="233"
            HorizontalAlignment="Left"
            Margin="12,58,0,0"
            Name="listBox1"
            VerticalAlignment="Top"
            Width="243">

            <ListBoxItem>string 1</ListBoxItem>
            <ListBoxItem>string 2</ListBoxItem>
            <ListBoxItem>string 3</ListBoxItem>

        </ListBox>

        <TreeView
            x:Name="colorTree"
            Height="377"
            HorizontalAlignment="Left"
            Margin="12,297,0,0"
            VerticalAlignment="Top"
            Width="243">

            <TreeView.ItemTemplate>

                <HierarchicalDataTemplate
                    ItemsSource="{Binding Children, Mode=OneTime}">
                    <StackPanel
                        Orientation="Horizontal">
                        <!-- These elements are bound to a FooViewModel object. -->
                        <CheckBox
                            Focusable="False"
                            IsChecked="{Binding IsChecked, Mode=TwoWay}"
                            Content="{Binding Name, Mode=OneTime}"
                            Margin="2, 1, 4, 1"
                            VerticalAlignment="Center" />
                    </StackPanel>
                </HierarchicalDataTemplate>
                
            </TreeView.ItemTemplate>
        </TreeView>
    </Grid>
</Window>
